//
//  RegCell.m
//  jinwang
//
//  Created by jzb on 2018/3/1.
//  Copyright © 2018年 jzb. All rights reserved.
//

#import "RegCell.h"

@implementation RegCell

- (void)awakeFromNib {
    [super awakeFromNib];
//    self.PhoneTF.delegate = self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark -UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    //限制手机号长度
    if ([textField isEqual:self.PhoneTF]) {
        NSUInteger length = textField.text.length + string.length - range.length;
        if (length <= 11) {
            return YES;
        }else{
            [self.PhoneTF shakeWithShakeDirection:ShakingDirectionHorizontal];
            return NO;
        }
    }else if ([textField isEqual:self.YanZhenMaTF]) {
        NSUInteger length = textField.text.length + string.length - range.length;
        if (length <= 6) {
            return YES;
        }else{
            [self.YanZhenMaTF shakeWithShakeDirection:ShakingDirectionHorizontal];
            return NO;
        }
    }else if ([textField isEqual:self.PassWordTF]) {
        NSUInteger length = textField.text.length + string.length - range.length;
        if (length <= 6) {
            return YES;
        }else{
            [self.PassWordTF shakeWithShakeDirection:ShakingDirectionHorizontal];
            return NO;
        }
    }
//    else if ([textField isEqual:self.user_nicknameTF]) {
//        NSUInteger length = textField.text.length + string.length - range.length;
//        if (length <= 5) {
//            return YES;
//        }else{
//            [self.user_nicknameTF shakeWithShakeDirection:ShakingDirectionHorizontal];
//            return NO;
//        }
//    }else if ([textField isEqual:self.user_truenameTF]) {
//        NSUInteger length = textField.text.length + string.length - range.length;
//        if (length <= 5) {
//            return YES;
//        }else{
//            [self.user_truenameTF shakeWithShakeDirection:ShakingDirectionHorizontal];
//            return NO;
//        }
//    }
    else{
        return YES;
    }
}

@end
